<template>
  <div>
    <button @click="isShow = true">点我弹窗</button>
    <teleport to="body">
      <div v-if="isShow" class="mask">
        <div class="dialog" v-if="isShow">
          <h2>我是一个弹窗</h2>
          <h3>内容</h3>
          <h3>内容</h3>
          <h3>内容</h3>
          <h3>内容</h3>
          <button @click="isShow = false">关闭弹窗</button>
        </div>
      </div>
    </teleport>
  </div>
</template>
<script>
import { ref } from "vue";
export default {
  setup() {
    let isShow = ref(false);
    return {
      isShow,
    };
  },
};
</script>
<style>
.mask{
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    background-color: rgba(0,0,0,.5);
}
.dialog {
  text-align: center;
  width: 300px;
  height: 300px;
  background-color: green;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
}
</style>